package com.nxn.core.web.action.test;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.nxn.core.model.Person;
import com.nxn.core.model.State;
import com.nxn.core.service.EntityManager;
import com.nxn.core.service.PersonService;
import com.nxn.core.web.action.base.CRUDAction;

@Controller("personAction")
@Scope("prototype")
//@Namespace("/person")
//@ParentPackage("basicstruts2")
//@Results( { @Result(name = "success", location = "/index.jsp") } )
public class PersonAction extends CRUDAction<Person, Long> {
	
	private static final long serialVersionUID = 1L;
	
	@Autowired
	private PersonService personService ;
	
	private String [] sports = {"football", "baseball", "basketball" };
	private String [] genders = {"male", "female", "not sure" };
	private List<State> states ;
	private String [] carModelsAvailable = {"Ford","Chrysler","Toyota","Nissan"};
	
	public EntityManager<Person, Long> getServiceImpl() {
		return personService;
	}
	
	public String input() throws Exception {
		
		return INPUT;
	}
	
	public List<String> getSports() {
		return Arrays.asList(sports);
	}
	
	public List<String> getGenders() {
		
		return Arrays.asList(genders);
		
	}

	public List<State> getStates() {
		
		states = new ArrayList<State>();
		states.add( new State("AZ", "Arizona") );
		states.add( new State("CA", "California") );
		states.add( new State("FL", "Florida") );
		states.add( new State("KS", "Kansas") );
		states.add( new State("NY", "New York") );
		
		return states;
	}

	public String [] getCarModelsAvailable() {
		return carModelsAvailable;
	}

}
